package com.zzl.example.springboottest.util;


import com.zzl.example.springboottest.bean.Person;
import org.apache.commons.lang3.math.NumberUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zengLiangZheng
 * @date 2022年11月02日 17:08
 */
public class StringUtil {
    public static void main(String[] args) {
        splitArr();
    }

    public static void splitArr(){
        String s = "jdkjfkd,jkjkdm,uieu,kijjf,ijkkkkd,";
        String[] sArr = s.split(",");
        for (String s1 : sArr) {
            System.out.println(s1);
        }
    }

    public static void stringLength(){
        System.out.println(("你好").length());
    }

    public static void splitStr(){
        String image = "http://res-test.qiumeiapp.com/xcx/proImagesbiskp34iYt.png,";
        String[] imageArr = image.split(",");
        System.out.println("imageArr.length="+imageArr.length);
        System.out.println("imageArr:"+imageArr[0]);
        System.out.println("image.substring(1, image.length()-1):"+image.substring(1, image.length()-1));
    }

    public static boolean isNumeric(String str) {
        return NumberUtils.isParsable(str);
    }

    public static void joinStr(BigDecimal decimal){
        System.out.println(decimal+"");
    }

    public static void modifiedList(){
        List<Person> personList = new ArrayList<>();

        // 添加Person对象到personList
        personList.add(new Person(1,"John"));
        personList.add(new Person(2,"Alice"));
        personList.add(new Person(3,"Bob"));

        String searchStr = "o";
        String replaceStr = "*";

        List<Person> modifiedList = new ArrayList<>();
        for (Person p : personList) {
            String s = p.getName().replaceAll(searchStr, replaceStr);
            p.setName(s);
            modifiedList.add(p);
        }

        System.out.println(modifiedList);
    }
}

    
